package logicQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("POST")
        url("/api/v3/logicQuizzes")
        headers {
            header("id", 1)
            contentType(applicationJsonUtf8())
        }
        body("""
            {
                "id":1,
                "hardCount":1,
                "normalCount":1,
                "easyCount":1,
                "timeBoxInMinutes":500,
                "description":"description",
                "exampleCount":1,
                "quizGroupId":1,
                "isAvailable":true
            }
            """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.hardCount', byRegex(number()))
            jsonPath('$.normalCount', byRegex(number()))
            jsonPath('$.easyCount', byRegex(number()))
            jsonPath('$.timeBoxInMinutes', byRegex(number()))
            jsonPath('$.description', byRegex("[\\s\\S]+"))
            jsonPath('$.exampleCount', byRegex(number()))
            jsonPath('$.quizGroupId', byRegex(number()))
            jsonPath('$.isAvailable', byRegex(anyBoolean()))
        }
    }
    response {
        status(201)
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
            {
                "uri":"asdasd",
                "id":1
            }
        """)
        bodyMatchers {
            jsonPath('$.uri', byRegex("[\\s\\S]+"))
            jsonPath('$.id', byRegex(number()))
        }
    }
}
